package org.guiceside.commons.collection;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

/**
 * <p>
 * request 参数封装工具类<br/>
 * 将request参数封装至RequestData
 * </p>
 * @author zhenjia  <a href='mailto:zhenjiaWang@gmail.com'>email</a>
 * @since JDK1.5
 * @version 1.0 $Date:200808
 * @see RequestData
 **/
public class DataUtility {
	private static final Logger log=Logger.getLogger(DataUtility.class);
	@SuppressWarnings("unchecked")
	public static RequestData<String,Object> getRequestData(HttpServletRequest req){
		RequestData<String,Object> requestData=new RequestData<String,Object>("REQUEST_DATA");
		String key;
		for(Enumeration e = req.getParameterNames(); e.hasMoreElements(); requestData.set(key, req.getParameter(key)))
        {
			 key = (String)e.nextElement();
			if(log.isDebugEnabled()){
				log.debug("parameterName["+key+"]→parameterValue["+req.getParameter(key)+"]");
			}
        }
		return requestData;
	}
}
